<template>
	<view class="container">
		<view class="carousel">
			<swiper indicator-dots circular=true duration="400">
				<swiper-item class="swiper-item" v-for="(item,index) in detailed.okami.imgList" :key="index">
					<view class="image-wrapper">
						<image :src="item.src" class="loaded" mode="aspectFit"></image>
					</view>
				</swiper-item>
			</swiper>
		</view>

		<view v-if="!detailed.okami.isServer" class="headavatar">需求</view>
		<view class="head">
			<view style="padding: 20upx;">
				<u-avatar :src="detailed.user.avatar" size="160"></u-avatar>
			</view>
			<view class="introduce-section">
				<text class="title">{{detailed.user.name}}</text>
				<u-tag style="margin-left: 20rpx;" :text="detailed.user.sexAge" :type="detailed.user.type"
					shape="circle" size="mini" />
				<view class="price-box">
					<!--<text class="price-tip">¥</text>
					<text class="price">341.6</text>
					<text class="m-price">¥488</text>
					<text class="coupon-tip">7折</text>-->
					<u-tag class="paly_tag" type="error" v-for="s in detailed.okami.requirement" :text="s" mode="plain"
						size="mini" />
				</view>
				<view class="bot-row">
					<text style="text-align: left;">浏览: {{detailed.user.views}}次</text>
					<text style="text-align: center;">接单: {{detailed.user.orderVolume}}次</text>
					<text style="text-align: right;">评分: {{detailed.user.score}}分</text>
				</view>
			</view>
		</view>
		<view class="c-list">
			<view class="c-row b-b">
				<view class="bz-list con">
					<text>{{detailed.user.signature}}</text>
				</view>
			</view>

			<view class="c-row b-b">
				<view>{{detailed.okami.describe}}</view>
			</view>
			<view class="info-title">个人资料</view>
			<view class="c-row b-b">
				<view style="padding-bottom: 10rpx;"><text
						style="color: #8b8b8b;padding-right: 10rpx;">账号：</text>{{detailed.user.id}}</view>
				<view style="padding-bottom: 10rpx;"><text
						style="color: #8b8b8b;padding-right: 10rpx;">生日：</text>{{detailed.user.birthday}}</view>
				<view style="padding-bottom: 10rpx;"><text
						style="color: #8b8b8b;padding-right: 10rpx;">星座：</text>{{detailed.user.constellation}}</view>
				<view style="padding-bottom: 10rpx;"><text
						style="color: #8b8b8b;padding-right: 10rpx;">地区：</text>{{detailed.user.region}}</view>
			</view>
			<view class="info-title">可玩游戏</view>
			<view class="c-row b-b">
				<view style="padding-bottom: 10rpx;"><text
						style="color: #8b8b8b;padding-right: 10rpx;">{{detailed.okami.gameName}}</text>{{detailed.okami.gameRank}}
				</view>
			</view>
			<view v-if="!detailed.okami.isServer" class="info-title">需求</view>
			<view v-if="!detailed.okami.isServer" class="cccc">
				<view>
					<u-tag type="info" class="rq-tag" v-for="s in detailed.okami.requirement" :text="s" />
				</view>
			</view>
		</view>

		<view class="info-title" style=" border-top: 1px solid #edeff3;">动态</view>
		<view v-if="dyns.length > 0" style="background: #FFFFFF;">
			<dynamic v-for="(item,index) in dyns" :key="item.id" :imgList="item.imgList" :avatar="item.avatar"
				:name="item.name" :publishTime="item.publishTime" :content="item.content" />
		</view>
		<view v-else class="no_body">
			<u-empty text="\n所谓伊人，在水一方\n\n居然没发现一条动态" mode="list"></u-empty>
		</view>
		<!-- 底部操作菜单 -->
		<view class="page-bottom">
			<view class="action-btn-group">
				<button type="primary" class=" action-btn no-border buy-now-btn"
					@click="follow">{{detailed.user.isFollow?"已关注":"关注"}}</button>
				<button type="primary" class=" action-btn no-border add-cart-btn" @click="paly">约玩</button>
			</view>
		</view>
	</view>
</template>

<script>
	import dynamic from '../../components/dynamic/dynamic.vue'
	export default {
		components: {
			dynamic
		},
		data() {
			return {
				id: 0,
				detailed: {
					user: {
						id: "654214",
						avatar: "http://img3.imgtn.bdimg.com/it/u=1150341365,1327279810&fm=26&gp=0.jpg",
						name: "名字可以有8个字", // 名字
						sexAge: "♀23", // 性别年龄
						type: "error",
						views: "254", // 浏览量
						orderVolume: "21", // 订单量
						score: "4.7",
						birthday: "2003-5-1",
						constellation: "水瓶座",
						region: "湖南 娄底 娄星区",
						signature: "签名二十个字签名二十签名二十个签名二十个",
						isFollow: false
					},
					okami: {
						isServer: false,
						describe: "描述两百个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个描述五十个",
						gameName: "第五人格",
						gameRank: "一阶",
						requirement: ["可爱", "声音好听", "不无聊", "带飞"],
						imgList: [{
								src: 'https://gd3.alicdn.com/imgextra/i3/0/O1CN01IiyFQI1UGShoFKt1O_!!0-item_pic.jpg_400x400.jpg'
							},
							{
								src: 'https://gd3.alicdn.com/imgextra/i3/TB1RPFPPFXXXXcNXpXXXXXXXXXX_!!0-item_pic.jpg_400x400.jpg'
							},
							{
								src: 'https://gd2.alicdn.com/imgextra/i2/38832490/O1CN01IYq7gu1UGShvbEFnd_!!38832490.jpg_400x400.jpg'
							},
							{
								src: 'https://gd2.alicdn.com/imgextra/i2/38832490/O1CN01IYq7gu1UGShvbEFnd_!!38832490.jpg_400x400.jpg'
							}
						],
					}
				},

				dyns: [{
						id: 1,
						avatar: 'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1950846641,3729028697&fm=26&gp=0.jpg',
						name: '小新',
						publishTime: 1617086756,
						content: '中国外交官这样讽加拿大总理，算不算骂？该不该骂？',
						imgList: [
							'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1976832114,2993359804&fm=26&gp=0.jpg',
							'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2369680151,826506100&fm=26&gp=0.jpg',
						],
						isFocusOn: true, // 是否已关注
					},

					{
						id: 2,
						avatar: 'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2291332875,175289127&fm=26&gp=0.jpg',
						name: '小白',
						publishTime: 1617036656,
						content: '  足不出户享国内核医学领域顶级专家云诊断，“中山-联影”分子影像远程互联融合创新中心揭牌 ',
						imgList: [
							'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2369680151,826506100&fm=26&gp=0.jpg',
						],
						isFocusOn: false,
					},
					{
						id: 3,
						avatar: 'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1950846641,3729028697&fm=26&gp=0.jpg',
						name: '小新',
						publishTime: 1617046556,
						content: '  外交部：一小撮国家和个人编造所谓新疆“强迫劳动”的故事，其心何其毒也！ ',
						imgList: [
							'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1976832114,2993359804&fm=26&gp=0.jpg',
							'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2369680151,826506100&fm=26&gp=0.jpg',
							'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1976832114,2993359804&fm=26&gp=0.jpg',
							'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1976832114,2993359804&fm=26&gp=0.jpg',
							'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1976832114,2993359804&fm=26&gp=0.jpg',
						],
						isFocusOn: false,
					},
					{
						id: 4,
						avatar: 'https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3717120934,3932520698&fm=26&gp=0.jpg',
						name: '小龙马',
						publishTime: 1616086456,
						content: 'DCloud有800万开发者,uni统计手机端月活12亿。是开发者数量和案例最丰富的多端开发框架。 欢迎知名开发商提交案例或接入uni统计。 新冠抗疫专区案例 uni-app助力',
						imgList: [
							'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2369680151,826506100&fm=26&gp=0.jpg',
							'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1976832114,2993359804&fm=26&gp=0.jpg',
							'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2369680151,826506100&fm=26&gp=0.jpg',
						],
						isFocusOn: false,
					},
					{
						id: 5,
						avatar: 'https://dss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2590128318,632998727&fm=26&gp=0.jpg',
						name: '风清扬',
						publishTime: 1607086356,
						content: '划个水',
						imgList: [
							'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2369680151,826506100&fm=26&gp=0.jpg',
							'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1976832114,2993359804&fm=26&gp=0.jpg',
							'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2369680151,826506100&fm=26&gp=0.jpg',
							'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1976832114,2993359804&fm=26&gp=0.jpg',
						],
						isFocusOn: false,
					}
				]

			};
		},
		async onLoad(options) {

			//接收传值,id里面放的是标题，因为测试数据并没写id 
			let id = options.id;
			if (id) {
				console.debug(id);
				this.id = id;
			}

			uni.request({
				url: this.httpRoot + 'okami/details',
				method: 'GET',
				data: {
					id: this.id
				},

				success: res => {
					console.debug(res);
					console.debug(res.data);
					var code = 0;
					var data = {};
					var message = '';
					if ('code' in res.data) {
						code = res.data.code;
					}
					if ('message' in res.data) {
						message = res.data.message;
					}
					if ('data' in res.data) {
						data = res.data.data;
						// data = res.data.data.parseJSON(); //由JSON字符串转换为JSON对象
						// data = JSON.parse(res.data.data);
						console.debug('数据：');
						console.debug(data);
						if ('detailed' in data) {
							this.detailed = data.detailed;
							console.debug(data.detailed);

							this.dyns = [];
						}
					} else {
						uni.showToast({
							title: '服务器错误',
							icon: 'none'
						});
					}
					if (message != '') {
						uni.showToast({
							title: message,
							icon: 'none'
						});
					}
				},
				fail: () => {
					uni.showModal({
						title: '请求数据失败'
					});
				},
				complete: () => {

				}
			});
		},
		methods: {
			paly() {
				if (this.checkLogin()) {
					uni.navigateTo({
						url: '../okami_create/okami_create?id=' + this.id
					});
				} else {
					uni.showToast({
						title: '请先登录',
						icon: 'none'
					});
				}
			},
			// 关注/取消关注
			follow() {
				if (this.checkLogin()) {

					if (this.detailed.user.isFollow) {
						uni.showToast({
							title: '已取消关注'
						});
						this.detailed.user.isFollow = false;
					} else {
						uni.showToast({
							title: '已关注'
						});
						this.detailed.user.isFollow = true;
					}
				} else {
					uni.showToast({
						title: '请先登录',
						icon: 'none'
					});
				}
			}
		},

	}
</script>

<style lang='scss'>
	page {
		background: $page-color-base;
		padding-bottom: 160upx;
	}

	.head {
		padding-top: 20upx;
		padding-left: 10upx;
		padding-bottom: 2upx;
		padding-right: 30upx;
		background-color: #FFFFFF;
		display: flex;
	}

	.info-title {
		padding: 10rpx 40rpx;

		display: flex;
		align-items: center;
		justify-content: space-between;

		font: bold 36rpx normal;

		background-color: #FFFFFF;
	}

	.icon-you {
		font-size: $font-base + 2upx;
		color: #888;
	}

	.carousel {
		height: 650upx;
		position: relative;

		swiper {
			height: 100%;
		}

		.image-wrapper {
			width: 100%;
			height: 100%;
		}

		.swiper-item {
			display: flex;
			justify-content: center;
			align-content: center;
			height: 750upx;
			overflow: hidden;

			image {
				width: 100%;
				height: 100%;
			}
		}

	}

	.rq-tag {
		margin-left: 10rpx;
	}

	.paly_tag {
		margin-left: 6rpx;
	}

	/* 标题简介 */
	.introduce-section {
		background: #fff;

		.title {
			font-size: 48upx;
			color: $font-color-dark;
			height: 50upx;
			line-height: 50upx;
		}

		.price-box {
			display: flex;
			align-items: baseline;
			height: 64upx;
			padding: 10upx 0;
			font-size: 26upx;
			color: $uni-color-primary;
		}

		.price {
			font-size: $font-lg + 2upx;
		}

		.m-price {
			margin: 0 12upx;
			color: $font-color-light;
			text-decoration: line-through;
		}

		.coupon-tip {
			align-items: center;
			padding: 4upx 10upx;
			background: $uni-color-primary;
			font-size: $font-sm;
			color: #fff;
			border-radius: 6upx;
			line-height: 1;
			transform: translateY(-4upx);
		}

		.bot-row {
			width: 400upx;
			display: flex;
			justify-content: space-around;
			height: 50upx;
			font-size: $font-sm;
			color: $font-color-light;

			text {
				flex: 1;
			}
		}
	}

	/* 分享 */


	.cccc {
		padding: 20upx 30upx;
		position: static;
	}

	.c-list {
		font-size: $font-sm + 2upx;
		color: $font-color-base;
		background: #fff;

		.c-row {
			/*display:flex;*/
			align-items: center;
			padding: 20upx 50upx;
			position: relative;
		}

		.tit {
			width: 140upx;
		}

		.con {
			flex: 1;
			color: $font-color-dark;

			.selected-text {
				margin-right: 10upx;
			}
		}

		.bz-list {
			height: 40upx;
			font-size: $font-sm+2upx;
			color: $font-color-dark;

			text {
				display: inline-block;
				margin-right: 30upx;
			}
		}

		.con-list {
			flex: 1;
			display: flex;
			flex-direction: column;
			color: $font-color-dark;
			line-height: 40upx;
		}

		.red {
			color: $uni-color-primary;
		}
	}

	/* 评价 */
	.eva-section {
		display: flex;
		flex-direction: column;
		padding: 20upx 30upx;
		background: #fff;
		margin-top: 16upx;

		.e-header {
			display: flex;
			align-items: center;
			height: 70upx;
			font-size: $font-sm + 2upx;
			color: $font-color-light;

			.tit {
				font-size: $font-base + 2upx;
				color: $font-color-dark;
				margin-right: 4upx;
			}

			.tip {
				flex: 1;
				text-align: right;
			}

			.icon-you {
				margin-left: 10upx;
			}
		}
	}

	.eva-box {
		display: flex;
		padding: 20upx 0;

		.portrait {
			flex-shrink: 0;
			width: 80upx;
			height: 80upx;
			border-radius: 100px;
		}

		.right {
			flex: 1;
			display: flex;
			flex-direction: column;
			font-size: $font-base;
			color: $font-color-base;
			padding-left: 26upx;

			.con {
				font-size: $font-base;
				color: $font-color-dark;
				padding: 20upx 0;
			}

			.bot {
				display: flex;
				justify-content: space-between;
				font-size: $font-sm;
				color: $font-color-light;
			}
		}
	}

	/*  详情 */
	.detail-desc {
		background: #fff;
		margin-top: 16upx;

		.d-header {
			display: flex;
			justify-content: center;
			align-items: center;
			height: 80upx;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			position: relative;

			text {
				padding: 0 20upx;
				background: #fff;
				position: relative;
				z-index: 1;
			}

			&:after {
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translateX(-50%);
				width: 300upx;
				height: 0;
				content: '';
				border-bottom: 1px solid #ccc;
			}
		}
	}



	/*  弹出层 */

	.headavatar {
		padding: 10rpx;
		z-index: 99;
		font-size: 36upx;
		text-align: center;
		width: 100%;
		color: #FFFFFF;
		background: linear-gradient(to left, #ffac30, #fa436a, #F56C6C);
	}

	/* 底部操作菜单 */
	.page-bottom {
		position: fixed;
		left: 30upx;
		bottom: 30upx;
		z-index: 95;
		display: flex;
		justify-content: space-around;
		align-items: center;
		width: 690upx;
		height: 100upx;
		/*background: rgba(255,255,255,.9);*/
		/*box-shadow: 0 0 20upx 0 rgba(0,0,0,.5);*/
		/*border-radius: 16upx;*/

		.p-b-btn {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: $font-sm;
			color: $font-color-base;
			width: 96upx;
			height: 80upx;

			.yticon {
				font-size: 40upx;
				line-height: 48upx;
				color: $font-color-light;
			}

			&.active,
			&.active .yticon {
				color: $uni-color-primary;
			}

			.icon-fenxiang2 {
				font-size: 42upx;
				transform: translateY(-2upx);
			}

			.icon-shoucang {
				font-size: 46upx;
			}
		}

		.action-btn-group {
			display: flex;
			height: 76upx;
			border-radius: 100px;
			overflow: hidden;
			box-shadow: 0 20upx 40upx -16upx #fa436a;
			box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
			background: linear-gradient(to right, #ffac30, #fa436a, #F56C6C);
			margin-left: 20upx;
			position: relative;

			&:after {
				content: '';
				position: absolute;
				top: 50%;
				right: 50%;
				transform: translateY(-50%);
				height: 28upx;
				width: 0;
				border-right: 1px solid rgba(255, 255, 255, .5);
			}

			.action-btn {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 180upx;
				height: 100%;
				font-size: $font-base;
				padding: 0;
				border-radius: 0;
				background: transparent;
			}
		}
	}

	.container {
		padding-bottom: env(safe-area-inset-bottom);
	}

	.tui-title {
		width: 100%;
		padding: 70rpx 30rpx 30rpx 30rpx;
		box-sizing: border-box;
		font-size: 30rpx;
		line-height: 30rpx;
		color: #666;
	}

	.tui-default {
		padding: 20rpx 30rpx;
	}

	.tui-article {
		position: relative;
	}

	.tui-article-img {
		width: 100%;
		height: 300rpx;
		display: block;
	}

	.tui-article-title {
		position: absolute;
		left: 0;
		bottom: 0;
		color: #fff;
		font-size: 32rpx;
		font-weight: 500;
		box-sizing: border-box;
		padding: 20rpx 30rpx;
		background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.6));
	}

	.tui-cell-title {
		font-size: 32rpx;
		font-weight: 500;
		padding: 0 10rpx;
		word-break: break-all;
		word-wrap: break-word;
	}

	.tui-cell-img {
		height: 160rpx;
		width: 160rpx;
	}

	.tui-flex {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.tui-mr {
		margin-right: 20rpx;
	}


	.tui-flex-pic {
		display: flex;
		display: -webkit-flex;
		justify-content: space-between;
		flex-direction: row;
		flex-wrap: wrap;
		box-sizing: border-box;
		background: #fff;
		padding: 0 120rpx;
	}

	.tui-flex-pic image {
		width: 32%;
		margin-bottom: 2%;
	}

	.tui-content {
		padding: 0rpx 30rpx 20rpx 120rpx;
		box-sizing: border-box;
		font-size: 34rpx;
		font-weight: 400;
		color: #333;
	}

	.tui-color-gray {
		color: #ccc;
	}

	.tui-pleft {
		padding-left: 120rpx;
	}

	.no_body {
		margin-top: 50rpx;
	}
</style>
